
/**
 * Module dependencies.
 */

var express = require('express'),
    routes = require('./routes'),
    configuration = require('./configuration/configuration').Configuration ,
    service = require('./service').Service,
    LobbyServer = require('./Server/LobbyServer').LobbyServer;


var app = module.exports = express.createServer();

require('./configuration/configuration').initializeExpressConfig(app, express);

app.get('/', routes.index);


service.init(configuration);

var lobbyServer = new LobbyServer(service, { host:'localhost',port : 8081});

lobbyServer.init(function() {
    lobbyServer.startServer();
});
app.listen(configuration.webserver_port, function(){
  console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});

//var obj1 = { name : 'Hung', age : 27 };
//var obj2 = { subject : 'English', teacher : 'Moon' };
//
//var obj = [obj1, obj2];
//
////var data1 = msgPack.pack(obj1);
////var data2 = msgPack.pack(obj2);
//var data = msgPack.pack(obj);
//
//var unData = msgPack.unpack(data);
//
//console.log(unData[1]);
//
////console.log(data1);
////var buffer1 = new Buffer(data1);
////var buffer2 = new Buffer(data2);
////var buffer = new Buffer(data1.length + data2.length);
////buffer1.copy(buffer);
////buffer2.copy(buffer, data1.length);
////
////console.log('Buffer tong la '+ buffer.length);
////
////var up1 = msgPack.unpack(buffer);
////
////console.log(up1);
//
////
////buffer.write(data1);
////buffer.write(data2,data1.length());
////
////console.log('Buffer length is ' + buffer.length());




